<div class="form-field">
<#if form.mode == "view">
    <div class="viewmode-field">
    </div>
<#else>
    <label for="prop_rccwf_personDivision">Skyriaus pavadinimas:<span class="mandatory-indicator">${msg("form.required.fields.marker")}</span></label>
    <input type="text" id="prop_rccwf_personDivision" name="prop_rccwf_personDivision" style="width: 600px"/><br>
    <label for="prop_rccwf_personPosition">Pareigos:<#if field.mandatory><span class="mandatory-indicator">${msg("form.required.fields.marker")}</span></#if></label>
    <input type="text" id="prop_rccwf_personPosition" name="prop_rccwf_personPosition" style="width: 600px"/><br>
    <label for="prop_rccwf_personFullName">Vardas ir pavardė:<#if field.mandatory><span class="mandatory-indicator">${msg("form.required.fields.marker")}</span></#if></label>
    <input type="text" id="prop_rccwf_personFullName" name="prop_rccwf_personFullName" style="width: 600px"/>
</#if>
</div>

<script type="text/javascript">//<![CDATA[
var updateFields = function(res) {
    var divisionHtmlId = "#prop_rccwf_personDivision";
    var positionHtmlId = "#prop_rccwf_personPosition";
    var fullNameHtmlId = "#prop_rccwf_personFullName";

    var result = eval('(' + res.serverResponse.responseText + ')');
    if (result.userInfo.length > 0) {
            $(divisionHtmlId).val(result.userInfo[0].organization);
            $(positionHtmlId).val(result.userInfo[0].jobTitle);
            var str = result.userInfo[0].firstName + " " + result.userInfo[0].lastName;
            $(fullNameHtmlId).val(str);
    } else {
        Alfresco.util.PopupManager.displayMessage({
            displayTime: 3,
            effectDuration: 1,
            text: 'Klaida gaunant informaciją apie naudotoją.'
        });
    }
};

Alfresco.util.Ajax.jsonGet({
    url : Alfresco.constants.PROXY_URI + "user/info/person/"+ (new Date().getTime()),
    successCallback : {
        fn : updateFields,
        scope : this
    },
    failureCallback : {
        fn : function() {
            Alfresco.util.PopupManager.displayMessage({
                displayTime: 3,
                effectDuration: 1,
                text: 'Klaida gaunant informaciją apie naudotoją.'
            });
        },
        scope : this
    }
});//]]>
</script>